package com.sgy.spring_ioc_xml_anno.pojo;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 拦截实例化之后的对象，实例化并且属性注入了
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("lazyResult".equals(beanName)) {
            System.out.println("postProcessBeforeInitialization拦截处理lazyResult");
        }
        return null;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if ("lazyResult".equals(beanName)) {
            System.out.println("postProcessAfterInitialization拦截处理lazyResult");
        }
        return null;
    }
}
